﻿// -------------------------------------------------------------------------
//    @FileName         :    NFCityPlayerQuestExt.cpp
//    @Author           :    Gao.Yi
//    @Date             :    2025-09-15
//    @Email			:    445267987@qq.com
//    @Module           :    NFCityPlayerQuestExt
//    @Desc             :
//
// -------------------------------------------------------------------------

#include "NFCityPlayerQuestExt.h"

NFCityPlayerQuestExt::NFCityPlayerQuestExt()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFCityPlayerQuestExt::~NFCityPlayerQuestExt()
{
}

int NFCityPlayerQuestExt::CreateInit()
{
    return 0;
}

int NFCityPlayerQuestExt::ResumeInit()
{
    return 0;
}

int NFCityPlayerQuestExt::InitQuestData(const proto_ff::CityRoleQuestData* pQuestData)
{
    CHECK_NULL(0, pQuestData);
    m_stQuestData.FromPb(*pQuestData);
    return 0;
}

bool NFCityPlayerQuestExt::HasQuest(int iQuestId) const
{
    if (GetQuest(iQuestId))
    {
        return true;
    }
    return false;
}

bool NFCityPlayerQuestExt::HasNonFinishTask(int iQuestId) const
{
    auto pQuest = GetQuest(iQuestId);
    if (pQuest)
    {
        for (int k = 0; k < (int)pQuest->event_node_list.size(); ++k)
        {
            if (pQuest->event_node_list[k].value < pQuest->event_node_list[k].condition_value)
            {
                return true;
            }
        }
    }
    return false;
}

QuestNode* NFCityPlayerQuestExt::GetQuest(int iQuestId)
{
    auto iter = m_stQuestData.accepted_list.find(iQuestId);
    if (iter != m_stQuestData.accepted_list.end())
    {
        return &iter->second;
    }
    return nullptr;
}

const QuestNode* NFCityPlayerQuestExt::GetQuest(int iQuestId) const
{
    auto iter = m_stQuestData.accepted_list.find(iQuestId);
    if (iter != m_stQuestData.accepted_list.end())
    {
        return &iter->second;
    }
    return nullptr;
}
